package unitTest;

import com.mic.yzzn.plc.common.control.RMI.PLCCollector;
import com.mic.yzzn.plc.common.control.datastructure.PLCData;
import com.mic.yzzn.plc.common.control.datastructure.PLCMissionResult;

import java.rmi.Naming;

public class CycleResultFetchTest
{
	public static void main(String[] args)
	{
		String name = "222.201.180.253-9094-01"; // 要获取的采集器的RMI绑定名
		int sleepTime = 1; // 获取周期结果的间隔，单位为s
		PLCCollector collector = null;
		
		try
		{
			collector = (PLCCollector) Naming.lookup(name);
			
			while (true)
			{
				PLCMissionResult result = collector.getCycleMissionResult(); // 获取所有周期结果
				for (PLCData data : result.getResultData())
				{
					System.out.println(data);
				}
				System.out.println("-------------------");
				
				Thread.sleep(sleepTime * 1000);
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}
